const axios = require('axios')
const DingTalk = require('dingtalk-robot-sdk')

function sendWechat (runningSchedule) {
  axios.post(runningSchedule.webhookUrl, {
    msgtype: 'text',
    text: {
      content: runningSchedule.message,
      mentioned_list: ['@all']
    }
  })
}

function sendDingTalk (runningSchedule) {
  const dingTalk = new DingTalk({
    accessToken: runningSchedule.accessToken,
    secret: runningSchedule.secret
  })
  const text = new DingTalk.Text(runningSchedule.message)
  dingTalk.send(text)
}

function sendFeishu (runningSchedule) {
  axios.post(runningSchedule.feishuWebhookUrl, {
    msg_type: 'text',
    content: {
      text: runningSchedule.message
    }
  })
}

module.exports = {
  sendDingTalk,
  sendFeishu,
  sendWechat
}
